#include <iostream>
#include <vector>

using namespace std;

int n, m, x, y;


int main() {
    cin >> n >> m;
    vector<vector<int> > v(n, vector<int>());

    for(int i = 0; i < m; i++) {
        cin >> x >> y;
        v[x-1].push_back(y);
    }

    for(vector<vector<int> >::iterator it = v.begin(); it != v.end(); it++) {
        for(vector<int>::iterator vit = it->begin(); vit != it->end(); vit++) {
            cout << *vit << " ";
        }
        cout << endl;
    }

    return 0;
}
